package com.lagou.rabbitmq.enums;

import lombok.Getter;

@Getter
public enum OrderStatusEnum {

    UNPAID(1, "未支付"),
    PAID(2, "完成支付"),
    INVALID(3, "已失效");

    private Integer code;
    private String name;

    OrderStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        for (OrderStatusEnum item : OrderStatusEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }
}
